#import <Foundation/Foundation.h>
#import "LoginModel.h"

NS_ASSUME_NONNULL_BEGIN

@class DeviceListItem;

FOUNDATION_EXTERN NSNotificationName const kUserDidLoginNotification;
FOUNDATION_EXTERN NSNotificationName const kUserDidLogoutNotification;
FOUNDATION_EXTERN NSNotificationName const kUserDidUpdateNotification;

FOUNDATION_EXTERN NSNotificationName const kUserDeviceListUpdateNotification;
FOUNDATION_EXTERN NSNotificationName const kUserDeviceListClearNotification;

typedef void(^AccountManagerLoginCompletion)(BOOL suc, LoginModel * _Nullable user);

/// 用户帐号管理
@interface AccountManager : NSObject

@property (nonatomic, strong) LoginModel *loginModel;

@property (nullable, nonatomic, strong) NSArray<DeviceListItem *> *deviceList;

+ (AccountManager *)shareAccount;

/// 用户登录
- (void)login:(LoginModel *)model;
/// 修改信息
- (void)update:(LoginModel *)model;
/// 退出登录
- (void)logout;
/// 是否已经登录
- (BOOL)didLogined;
/// 获取token
- (nullable NSString *)token;
/// 获取用户UUID
- (nullable NSString *)userUUID;

+ (void)loginIfNeed:(UIViewController *)from completion:(AccountManagerLoginCompletion)completion;

/// 弹出用户协议框
- (BOOL)needPromptAgreement;

/// 清除弹用户协议标识
- (void)clearPromptAgreement;

/// 保存用户设备列表
- (void)saveDeviceList:(NSArray<DeviceListItem *> *)list;

/// 清除用户设备列表
- (void)clearDeviceList;

/// 获取用户IMEI号
- (NSString *)deviceImei;

/// 获取设备MAC地址
- (NSString *)deviceMac;


@end

NS_ASSUME_NONNULL_END
